package server2;

import java.util.concurrent.*;

public  class threadPool {

    private static ThreadPoolExecutor threadPoolExecutor;
    // 定义一个线程池
    private static int corePoolSize = 10;
    private static int maximumPoolSize =50;
    private static long keepAliveTime = 100L;
    private static TimeUnit unit = TimeUnit.SECONDS;
    private static BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(50);
    private static ThreadFactory threadFactory = Executors.defaultThreadFactory();
    private static RejectedExecutionHandler handler = new ThreadPoolExecutor.AbortPolicy();


    static {
        threadPoolExecutor = new ThreadPoolExecutor(
                corePoolSize,
                maximumPoolSize,
                keepAliveTime,
                unit,
                workQueue,
                threadFactory,
                handler
        );
    }
    public static  ThreadPoolExecutor getthreadPoolExecutor(){
        return threadPoolExecutor;
    }
}
